package com.jswlw.service.biz.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jswlw.dao.biz.DistributionRecordMapper;
import com.jswlw.entity.biz.DistributionRecord;
import com.jswlw.service.biz.DistributionRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Service
public class DistributionRecordServiceImpl implements DistributionRecordService {

    @Autowired
    DistributionRecordMapper mapper;

    @Override
    public void add(DistributionRecord distributionRecord) {
        mapper.insert(distributionRecord);
    }

    @Override
    public void update(DistributionRecord distributionRecord) {
        mapper.updateByPrimaryKeySelective(distributionRecord);
    }

    @Override
    public int totalAmount(Integer distributorId, Date startTime, Date endTime) {
        return mapper.totalAmount(distributorId, startTime, endTime);
    }

    @Override
    public Page<DistributionRecord> queryPage(DistributionRecord filter) {
        PageHelper.startPage(filter.getOffset(), filter.getLimit());
        return (Page<DistributionRecord>) mapper.queryList(filter);
    }

    @Override
    public List<DistributionRecord> queryList(DistributionRecord filter) {
        return mapper.queryList(filter);
    }

    @Override
    public int totalAmount4Distributor(DistributionRecord filter) {
        return mapper.totalAmount4Distributor(filter);
    }
}
